package com.asj.house.controller;


import com.asj.house.entity.HouseRoom;
import com.asj.house.returns.RespEntity;
import com.asj.house.returns.RespTable;
import com.asj.house.service.HouseRoomService;
import com.asj.house.vo.param.PageParam;
import com.asj.house.vo.param.RoomParam;
import com.asj.house.vo.param.UserParam;
import io.swagger.annotations.Api;
import java.util.List;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 房屋信息表 前端控制器
 * </p>
 *
 * @author asj
 * @since 2021-03-16
 */
@RestController
@RequestMapping("/house-room")
@Slf4j
@Api(value = "房源总览接口", tags = "房源总览接口")
public class HouseRoomController {

    @Resource
    private HouseRoomService houseRoomService;

    @GetMapping("/list")
    @ApiOperation(value = "房源总览列表")
    public RespTable<List<HouseRoom>> listHouseRoom(RoomParam roomParam) {
        RespTable<List<HouseRoom>> respTable = houseRoomService.listHouseRoom(roomParam);
        return respTable;
    }

    @PostMapping("/insert")
    @ApiOperation(value = "新增房源")
    public RespEntity insertHouseRoom(@RequestBody HouseRoom houseRoom) {
        RespEntity respEntity = houseRoomService.insertHouseRoom(houseRoom);
        return respEntity;
    }

    @PutMapping("/update")
    @ApiOperation(value = "编辑房源")
    public RespEntity updateHouseRoom(@RequestBody HouseRoom houseRoom) {
        RespEntity respEntity = houseRoomService.updateHouseRoom(houseRoom);
        return respEntity;
    }

    @DeleteMapping("/delete")
    @ApiOperation(value = "删除房源")
    @ApiImplicitParam(paramType = "delete", dataType = "Integer", name = "roomId", value = "房源id", required = true)
    public RespEntity deleteHouseRoom(@RequestParam(value = "roomId", required = true) Integer roomId) {
        RespEntity respEntity = houseRoomService.deleteHouseRoom(roomId);
        return respEntity;
    }

    @DeleteMapping("/deleteBatch")
    @ApiOperation(value = "批量删除房源")
    public RespEntity deleteBatchHouseRoom(@RequestParam(value = "roomIds", required = true) Integer[] roomIds) {
        RespEntity respEntity = houseRoomService.deleteBatchHouseRoom(roomIds);
        return respEntity;
    }



}
